/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            aStaffDetailPurchaseApplyInfo: {
                purchaseApplys: [],
                staffId: '',
                tel: ''
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('aStaffDetailPurchaseApply', 'switch', function (_data) {
                $that.aStaffDetailPurchaseApplyInfo.staffId = _data.staffId;
                $that.aStaffDetailPurchaseApplyInfo.tel = _data.tel;
                $that._loadAStaffDetailPurchaseApplyData(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('aStaffDetailPurchaseApply', 'paginationPlus', 'page_event',
                function (_currentPage) {
                    $that._loadAStaffDetailPurchaseApplyData(_currentPage, DEFAULT_ROWS);
                });
        },
        methods: {
            _loadAStaffDetailPurchaseApplyData: function (_page, _row) {
                let param = {
                    params: {
                        page: _page,
                        row: _row,
                        resOrderType: '10000',
                        endUserTel: $that.aStaffDetailPurchaseApplyInfo.tel,
                    }
                };
                //发送get请求
                vc.http.apiGet('/purchaseApply.listAdminPurchaseApplys',
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        $that.aStaffDetailPurchaseApplyInfo.purchaseApplys = _json.purchaseApplys;
                        vc.emit('aStaffDetailPurchaseApply', 'paginationPlus', 'init', {
                            total: _json.records,
                            dataCount: _json.total,
                            currentPage: _page
                        });
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _qureyAStaffDetailPurchaseApply: function () {
                $that._loadAStaffDetailPurchaseApplyData(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _openDetailPurchaseApplyModel: function (_purchaseApply) {
                vc.jumpToPage("/#/pages/common/purchaseApplyDetail?applyOrderId=" + _purchaseApply.applyOrderId + "&resOrderType=10000");
            },
        }
    });
})(window.vc);